﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DigDes.DSchool.SUPS.DataAccess.Database;
using DigDes.DSchool.SUPS.DataAccess.Interface;

namespace MVCSUPS.Controllers
{
    public class ReportController : Controller
    {
        //
        // GET: /Report/

        public ActionResult Index()
        {
            List<ReportData> table = ReportLoader.GetAllReports();
            ViewData["table"] = table;
            return View();
        }

        [HttpPost]
        public ActionResult Index(ReportData selectedCar)
        {
            if (selectedCar.CarNumber != null)
            {
                List<ReportData> table = ReportLoader.GetSelectedCarReports(selectedCar.CarNumber);
                ViewData["table"] = table;
                return View();
            }
            else
            {
                return Index();
            }
            
        }

    }
}